package com.community.web.master.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.community.model.entity.Goods;
import com.community.web.master.domain.vo.GoodsWithCategoryNameVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 李晶
 * @since 2024-07-02
 */
public interface GoodsMapper extends BaseMapper<Goods> {

    List<GoodsWithCategoryNameVo> selectPageByMap(Map<String, Object> map);

    @Select("select goods.id, goods.goods_no, goods.goods_name, goods.category_id, goods.goods_introduce, goods.goods_content, goods.goods_state, goods.goods_picture, goods.goods_market_price, goods.create_time, goods.update_time,  gc.category_name" +
            " from goods join goods_category gc on gc.id = goods.category_id where goods.id=#{id}")
    GoodsWithCategoryNameVo getGoodsById(Integer id);

    @Select("select goods.id, goods.goods_no, goods.goods_name, goods.category_id, goods.goods_introduce, goods.goods_content, goods.goods_state, goods.goods_picture, goods.goods_market_price, goods.create_time, goods.update_time,  gc.category_name" +
            " from goods left outer join goods_category gc on gc.id = goods.category_id")
    List<GoodsWithCategoryNameVo> getAllGoods();
}
